package com.fire.control.system.module.device.controller.app;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fire.control.system.IndexController;
import com.fire.control.system.module.common.controller.BaseController;
import com.fire.control.system.module.device.service.AppDeviceService;
import com.fire.control.system.standard.BusinessInterfaceStandard;
import com.fire.control.system.support.protocol.app.AppRequestProtocol;
import com.fire.control.system.support.protocol.comman.ResponseProtocol;

/**
 * 
 * @ClassName:  AppDeviceController
 * @Description:  app地图--设备控制器
 * @author:  xiechengguang
 * @date:  2017年6月13日 下午5:55:26
 *
 */
@Controller
@RequestMapping(value = "/app/device")
public class AppDeviceController extends BaseController implements BusinessInterfaceStandard<AppRequestProtocol,ResponseProtocol> {
	private static final Logger logger = LoggerFactory.getLogger(AppDeviceController.class);
	@Autowired
	private AppDeviceService appDeviceService;
	
	/**
	 * 
	 * @Title: index   
	 * @Description: app端获取所有设备
	 * @param:        
	 * @return: ResponseJsonProtocol      
	 * @throws
	 */
	@RequestMapping(value = "/getDevices", method = RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getDevices(@RequestBody AppRequestProtocol requestProtocol){
		logger.info("getDevices (" + requestProtocol.getTaskuuid() + ") task In time: "+System.currentTimeMillis());
		ResponseProtocol response = appDeviceService.getDevices(requestProtocol, getUser());
		logger.info("getDevices (" + requestProtocol.getTaskuuid() + ") task Out time: "+System.currentTimeMillis());
		return response;
	}
	
	/**
	 * @author: xiechengguang 
	 * @Title: getPlaneInfo   
	 * @Description: 根据设备id获取设备平面图详细信息  
	 * @param:        
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value = "/getPlaneInfo", method = RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getPlaneInfo(@RequestBody AppRequestProtocol requestProtocol){
		
		return appDeviceService.getPlaneInfo(requestProtocol);
	}
	
	/**
	 * @author: xiechengguang 
	 * @Title: getSideInfo   
	 * @Description: 根据设备id获取设备侧面图详细信息  
	 * @param:        
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value = "/getSideInfo", method = RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getSideInfo(@RequestBody AppRequestProtocol requestProtocol){
		
		return appDeviceService.getSideInfo(requestProtocol);
	}
	
	/**
	 * @author: xiechengguang 
	 * @Title: getAllBuildingDevices   
	 * @Description: 根据当前设备获取楼栋所有设备，统计每层
	 * @param:        
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value = "/getAllBuildingDevices", method = RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getAllBuildingDevices(@RequestBody AppRequestProtocol requestProtocol){
		
		return appDeviceService.getAllBuildingDevices(requestProtocol, getUser());
	}
	
	
}
